package com.camel.docker.entity.docker;

import com.github.dockerjava.api.command.PullImageResultCallback;
import com.github.dockerjava.api.model.PullResponseItem;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

@Component
public class MyPullImageResultCallback extends PullImageResultCallback {
    @Override
    public void onError(Throwable throwable) {
        System.out.println("镜像下载错误，请检查配置信息，及镜像地址是否可达");
        super.onError(throwable);
    }

    @Override
    public void onNext(PullResponseItem item) {
        System.out.println(ObjectUtils.isEmpty(item.getProgress()) ? item.getProgress() : "");
        super.onNext(item);
    }

    @Override
    public void onComplete() {
        System.out.println("下载镜像完成");
        super.onComplete();
    }

    public MyPullImageResultCallback() {
        super();
    }
}
